<div class="cate">
	<div class='left-t'><h4>图片分类</h4></div>
	<ul class='cate-items'>
	<!--{foreach from=$category item=val}-->
		<li class='cate-items-li'>
			<span><a href="" target="_blank"><!--{$val.cname}--></a><font>(1214542)</font></span>
			<div class="item">
				<ul>
				<!--{foreach from=$val.child item=v}-->
					<li class="item-li">
						<span><a href="" target="_blank"><!--{$v.cname}--></a><font>(4112)</font></span>
						<ul>
						<!--{foreach from=$v.child item=l}-->
							<li><a href="" target="_blank"><!--{$l.cname}--></a></li>
						<!--{/foreach}-->
						</ul>
					</li>
				<!--{/foreach}-->
				</ul>
			</div>
		</li>
	<!--{/foreach}-->
	<!--{foreach from=$category item=val}-->
		<li class='cate-items-li'>
			<span><a href="" target="_blank"><!--{$val.cname}--></a><font>(1214542)</font></span>
			<div class="item">
				<ul>
				<!--{foreach from=$val.child item=v}-->
					<li class="item-li">
						<span><a href="" target="_blank"><!--{$v.cname}--></a><font>(4112)</font></span>
						<ul>
						<!--{foreach from=$v.child item=l}-->
							<li><a href="" target="_blank"><!--{$l.cname}--></a></li>
						<!--{/foreach}-->
						</ul>
					</li>
				<!--{/foreach}-->
				</ul>
			</div>
		</li>
	<!--{/foreach}-->
	<!--{foreach from=$category item=val}-->
		<li class='cate-items-li'>
			<span><a href="" target="_blank"><!--{$val.cname}--></a><font>(1214542)</font></span>
			<div class="item">
				<ul>
				<!--{foreach from=$val.child item=v}-->
					<li class="item-li">
						<span><a href="" target="_blank"><!--{$v.cname}--></a><font>(4112)</font></span>
						<ul>
						<!--{foreach from=$v.child item=l}-->
							<li><a href="" target="_blank"><!--{$l.cname}--></a></li>
						<!--{/foreach}-->
						</ul>
					</li>
				<!--{/foreach}-->
				</ul>
			</div>
		</li>
	<!--{/foreach}-->
		
	</ul>
</div>
<script>
	$('.cate-items > li').hover(
		function(){$(this).children('.item').show();sort(this);$(this).css({'background':'#E9E9E9','height':'24px'})},
		function(){$(this).children('.item').hide();$(this).css({'background':'','height':''})}
	)

	var W = 131;
	function sort(t)
	{
		var h = [];
		var box = $(t).find(".item-li");
		for(var i = 0; i < box.length; i++)
		{  
			var boxH = box.eq(i).height();
			if(i < 6)
			{
				h[i] = boxH;

			}else{
				var minH = Math.min.apply({},h);
				var minKey = getminKey(h, minH);
					h[minKey] += boxH;

				box.eq(i).css({
					"position" : 'absolute',
					"top" : minH,
					"left" : minKey * W+10,
					"border-top" : '1px dashed #808080'
				})
				if(minKey==5 )
				{
					box.eq(i).css({"border-right" : 0});
				}
			}

			if(i==5 || minKey==5)
			{
				box.eq(i).css({"border-right" : 0});
			}
		}
		$(t).find(".item").css({'height':Math.max.apply({},h)})
	}

	/* 返回数组中某一值的对应项数 */
	function getminKey(s, v) 
	{
		for(k in s) {
			if(s[k] == v) {
				return k;
			}
		}
	};
</script>